package lxt.dao.impl;

import java.util.ArrayList;
import java.util.List;

import lxt.dao.CostFineDao;
/**
 * 违章罚款管理dao
 * @author Lit
 *
 */
public class CostFineDaoImpl extends ABseDaoImpl implements CostFineDao {

	@SuppressWarnings("unchecked")
	public List<Object> loadAllCostFine(String truckId, String driverId,
			int offset, int length) {
		StringBuffer hql = new StringBuffer("Select tc,td.name from CostFine tc,DriverInfo td where tc.driverId = td.id ");
		ArrayList<Object> param = new ArrayList<Object>();
		if(truckId!=null&&!truckId.equals("")){
			hql.append(" And tc.truckId like ? ");
			param.add("%"+truckId+"%");
		}
		if(driverId!=null&&!driverId.equals("")){
			hql.append(" And td.name like ? ");
			param.add("%"+driverId+"%");
		}
		
		return (List<Object>)this.queryForPage(hql.toString(), param, offset, length);
	}

	public int loadAllCostFineCount(String truckId, String driverId) {
		StringBuffer hql = new StringBuffer("Select tc,td.name from CostFine tc,DriverInfo td where tc.driverId = td.id ");
		ArrayList<Object> param = new ArrayList<Object>();
		if(truckId!=null&&!truckId.equals("")){
			hql.append(" And tc.truckId like ? ");
			param.add("%"+truckId+"%");
		}
		if(driverId!=null&&!driverId.equals("")){
			hql.append(" And td.name like ? ");
			param.add("%"+driverId+"%");
		}
		return this.getAllRowCount(hql.toString(), param);
	}

}
